import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MusicVO, MusicForm, MusicQuery } from '@/api/business/music/types';

/**
 * 查询音乐列表
 * @param query
 * @returns {*}
 */

export const listMusic = (query?: MusicQuery): AxiosPromise<MusicVO[]> => {
  return request({
    url: '/business/music/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询音乐详细
 * @param id
 */
export const getMusic = (id: string | number): AxiosPromise<MusicVO> => {
  return request({
    url: '/business/music/' + id,
    method: 'get'
  });
};

/**
 * 新增音乐
 * @param data
 */
export const addMusic = (data: MusicForm) => {
  return request({
    url: '/business/music',
    method: 'post',
    data: data
  });
};

/**
 * 修改音乐
 * @param data
 */
export const updateMusic = (data: MusicForm) => {
  return request({
    url: '/business/music',
    method: 'put',
    data: data
  });
};

/**
 * 删除音乐
 * @param id
 */
export const delMusic = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/music/' + id,
    method: 'delete'
  });
};
